package com.wl.eb.controller;

import com.wl.eb.module.EbUser;
import com.wl.eb.service.RegistService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
@RequestMapping("/regist")
public class RegistController {
@Resource
    private RegistService registService;

    //返回注册
    @GetMapping("/reg")
    public String reg(){
        return  "register";
    }

    @RequestMapping("/registin")
    public  String regist(EbUser ebUser){
        System.out.println("==LoginController的login方法，ebUser:"+ebUser);
        //1.调用service进行登录
        boolean result = registService.regist(ebUser);
        if(!result){
            throw new RuntimeException("注册失败！！！");
        }
        //2.不绑定数据到model

        //3.返回View
        return "redirect:/login/on";
    }

}
